package com.jeesite.modules.jydq.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.jydq.entity.JydqCategory;
import com.jeesite.modules.jydq.dao.JydqCategoryDao;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 商品分类表Service
 * @author dong
 * @version 2025-03-20
 */
@Service
public class JydqCategoryService extends CrudService<JydqCategoryDao, JydqCategory> {
	
	/**
	 * 获取单条数据
	 * @param jydqCategory
	 * @return
	 */
	@Override
	public JydqCategory get(JydqCategory jydqCategory) {
		return super.get(jydqCategory);
	}
	
	/**
	 * 查询分页数据
	 * @param jydqCategory 查询条件
	 * @param jydqCategory page 分页对象
	 * @return
	 */
	@Override
	public Page<JydqCategory> findPage(JydqCategory jydqCategory) {
		return super.findPage(jydqCategory);
	}
	
	/**
	 * 查询列表数据
	 * @param jydqCategory
	 * @return
	 */
	@Override
	public List<JydqCategory> findList(JydqCategory jydqCategory) {
		return super.findList(jydqCategory);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param jydqCategory
	 */
	@Override
	@Transactional
	public void save(JydqCategory jydqCategory) {
		try {
			super.save(jydqCategory);
		} catch (Exception e){
			throw newValidationException("分类名称重复");
		}

	}
	
	/**
	 * 更新状态
	 * @param jydqCategory
	 */
	@Override
	@Transactional
	public void updateStatus(JydqCategory jydqCategory) {
		super.updateStatus(jydqCategory);
	}
	
	/**
	 * 删除数据
	 * @param jydqCategory
	 */
	@Override
	@Transactional
	public void delete(JydqCategory jydqCategory) {
		super.delete(jydqCategory);
	}

	@Transactional
	public void addViewCount(String categoryId) {
		dao.addViewCount(categoryId);
	}

	@Transactional
	public void addComparisonsCount(String categoryId) {
		dao.addComparisonsCount(categoryId);
	}
}